package test.the3nplus1;

public class The3nplus1 {
	
	public static void main(String args[]) {
		The3nplus1 cycle = new The3nplus1();
		cycle.getCycle(1, 10);
	}
	
	public void getCycle(int start, int end) {
		
		int cyclelen = 0;
		int tempCycleLen = 0;
		
		for (int i=start; i<=end; i++) {
			int n = i;
			while (n != 1) {
				if ((n % 2) == 0) {
					n = n / 2;
				} else {
					n = (n * 3) + 1;
				}
                tempCycleLen++;
            }
            tempCycleLen++;
            
            if (tempCycleLen > cyclelen) {
                cyclelen = tempCycleLen;
            }
            tempCycleLen = 0;
        }
		
		System.out.println(start + " " + end + " " + cyclelen);
    }
}
